package com.ruoyi.resume.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.resume.domain.request.LabelingRequest;
import com.ruoyi.resume.service.EducationBackgroundLabelingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "标签识别与存储")
@RestController
@RequestMapping("/education-background-labeling")
public class EducationBackgroundLabelingController {

    @Autowired
    private EducationBackgroundLabelingService educationBackgroundLabelingService;

    /**
     * 生成学校类别标签
     * @param request 包含学校类别的对象
     * @return 学校类别标签键值对列表
     */
    @ApiOperation(value = "生成学校类别标签",
            notes = "通过传入学校名称列表，生成对应的学校类别标签")
    @PostMapping("/school-type")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> educationBackgroundLabelingSchoolType(
            @ApiParam(value = "包含学校类别的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成学校类别标签
        List<Map<String, Integer>> result = educationBackgroundLabelingService.processSchoolTypeRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }

    /**
     * 生成专业类别标签
     * @param request 包含专业类别的对象
     * @return 专业类别标签键值对列表
     */
    @ApiOperation(value = "生成专业类别标签",
            notes = "通过传入专业名称列表，生成对应的专业类别标签")
    @PostMapping("/major-type")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> educationBackgroundLabelingMajorType(
            @ApiParam(value = "包含专业类别的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成专业类别标签
        List<Map<String, Integer>> result = educationBackgroundLabelingService.processMajorTypeRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }

    /**
     * 生成是否应届生标签
     * @param request 包含毕业时间的对象
     * @return 是否应届生标签键值对列表
     */
    @ApiOperation(value = "生成是否应届生标签",
            notes = "通过传入毕业时间信息，生成是否应届生标签")
    @PostMapping("/is-graduated")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> educationBackgroundLabelingIsGraduated(
            @ApiParam(value = "包含毕业时间的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成是否应届生标签
        List<Map<String, Integer>> result = educationBackgroundLabelingService.processGraduatedRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }

    /**
     * 生成最高学历标签
     * @param request 包含学历信息的对象
     * @return 最高学历标签键值对列表
     */
    @ApiOperation(value = "生成最高学历标签",
            notes = "通过传入学历信息，生成对应的最高学历标签")
    @PostMapping("/highest-degree")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> educationBackgroundLabelingHighestDegree(
            @ApiParam(value = "包含学历信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成最高学历标签
        List<Map<String, Integer>> result = educationBackgroundLabelingService.processHighestDegreeRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }
}
